Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get rid of ROOTFSCFG hack on ISO platform #90

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

luzbel
Copy link

@luzbel luzbel commented Feb 7, 2017

Modify grub.cfg: Pass json.cfg to kernel using a multiboot module instead of reading json.cfg from rootfs

This allow simple diskless unikernels to boot on baremetal or on hypervisors without virtio support (like Hyper V or VirtualBox ) while PCI IDE drivers aren't built by default.

Current grub.cfg generated by "rumprun iso"

set timeout=0
menuentry "rumpkernel" {
	multiboot /boot/unikernel.bin _RUMPRUN_ROOTFSCFG=/json.cfg
}

New grub.cfg generated by "rumprun iso"

set timeout=0
menuentry "rumpkernel" {
	multiboot /boot/hello.hw_generic.bin 
	module /json.cfg cmdline  
}

Modify grub.cfg: Pass json.cfg to kernel using a multiboot module instead of reading json.cfg from rootfs
This allow simple diskless unikernels to boot on baremetal or on hypervisors without virtio support (like Hyper V or VirtualBox ) while PCI IDE drivers aren't built by default.
@anttikantee
Copy link
Member

Can you expand on the usage after your change?

Also, I'm not sure if your assertion is correct. You should be able to use cookfs to create an image which you can bake and access at runtime without any I/O drivers. (at least I think that works)

@luzbel
Copy link
Author

luzbel commented Feb 9, 2017

Usage before:

  1. compile unikernel
  2. rumprun-bake ...
  3. rumprun iso ...
    this works ok on kvm or xen, but "fails to mount rootfs from image" on Hyper-V (and probably on VirtualBox)

I want to remark, rumprun iso autogenerated grub.cfg and json.cfg, so developer not need to know about those files, and this is what i expect for one tool designed to help developers not to deal with some internals.

If you want to run on Hyper-V, theory said you can bake a rootfs, but
a) you must known in advance you need to build json.cfg, known its format and bake in your image.
b) I can't found any documents and examples about using cookfs except node example, but the example don't cover rootfs (I suspect cookfs may generate valid data fs, but is not suitable for rootfs). Sure an expert rumprun kernel developer can figure it out how to make a rootfs with cookfs, but one of rumprun goals is to simplify , isn't it?
c)Anyway, I tried this sequence
c.1) compile unikernel
c.2) mkdir rootfs ; vi rootfs/json.cfg
c.3) x86_64-rumprun-netbsd-cookfs s0.fs rootfs
c.4) rumprun-bake -m "add s0.fs" hw_generic s0.bin unikernel
c.5) rumprun iso s0.bin
c6) qemu-system-x86_64 -curses -s -cdrom rumprun-s0.bin.iso
This fails with "mkdir /rootfs failed: File exists"
d) I tried also this sequence
c.1) compile unikernel
c.2) mkdir rootfs ; vi rootfs/json.cfg
c.3) x86_64-rumprun-netbsd-cookfs -s 1 s1.fs rootfs
c.4) rumprun-bake -m "add s1.fs" hw_generic s1.bin unikernel
c.5) rumprun iso s1.bin
c6) qemu-system-x86_64 -curses -s -cdrom rumprun-s1.bin.iso
This fails with "failed to mount rootfs from image"
e) unikernels seems not so funny at this point

Usage after:

  1. compile unikernel
  2. rumprun-bake
  3. rumprun iso

Just the standard(?) way described in this tutorial: compile, bake and run. (Ok, we can said that cookfs generate an object which is part of the compilation and baking process)
Furthermore, you are using a standar way to pass parameters to the kernel (multiboot protocol) instead of an ugly ad-hoc hack (_RUMPRUN_ROOTFSCFG)

I hope this is not going to be another long boring thread like so many in the rumpkernel-user email list. This is your repo, accept or reject the PR, but I can't say much more for only two lines of code.

@anttikantee
Copy link
Member

Where is the config file accessible from at runtime?

@luzbel
Copy link
Author

luzbel commented Feb 9, 2017

cmdline = (char *)(uintptr_t)mbm[0].mod_start;

@luzbel
Copy link
Author

luzbel commented May 19, 2017

I don't understand this comment on code

First (and for now, only) multiboot module loaded is used as preferred source for configuration

multiboot module is preferred source for configuration but grub.cfg is not using it?

@mato
Copy link
Member

mato commented May 29, 2017

@luzbel To explain what this does, since I wrote that code:

A multiboot module is just a file on the bootloader's filesystem which gets loaded into memory as a blob alongside the kernel, so it can contain anything. In this case if a module is present we inspect it to see if it looks like a JSON configuration and if so use it instead of looking for the configuration on the "kernel command line". So, in the GRUB example you would load the module with something like module config.json and not specify any command line in grub.cfg.

@anttikantee The config is not accessible as a file at runtime, only as multiboot_cmdline[] in rumprun.

@luzbel
Copy link
Author

luzbel commented May 29, 2017

So, in the GRUB example you would load the module with something like module config.json and not specify any command line in grub.cfg.

This is what PR does.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants